<!DOCTYPE html>
<!-- saved from url=(0042)http://v.bootstrapmb.com/2019/10/pgla6358/ -->
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
	<title>信息绑定</title>
	<link rel="stylesheet" type="text/css" href="style.css" />
	<script type="text/javascript" src="./jquery.min.js.下载"></script>
	<script type="text/javascript" src="./matching.js.下载"></script>
	<link rel="stylesheet" href="./css/larea.css">


</head>

<body sroll="no" onclick="onload">
	<form name="form1">
		<div class="div_fh">
			学员信息
		</div>
		<div class="div_f">
			<div class="div_col" id="me">
				<div class="div_c_l">
					<span> 学生姓名</span>
				</div>
				<div class="div_c_r">
					<input type="text" style="width:calc(100% - 16px);" name="name" id="name" placeholder="请填写真实姓名">
					<span style="float: right;margin-top: -30px;background:#fff" id="tish"></span>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="div_f">
			<div class="div_col" id="me">
				<div class="div_c_l">
					<span>性别</span>
				</div>
				<div class="div_c_r">
					<select id="sex">
						<option disabled style="display: none" selected value>请选择性别 </option>
						<option value="1">男</option>
						<option value="2">女</option>
					</select>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="div_f">
			<div id="me">
				<div class="div_c_l">
					<span>选择校区</span>
				</div>
				<div class="div_c_r">
					<div class="content-block">
						<input name="school" id="demo1" type="text" readonly="" value="请选择校区" />
						<input name="schoolval" id="value1" type="hidden" value="1,57,58" onblur="schoolChange() " />
					</div>
				</div>


			</div>
			<div style="clear:both"></div>
		</div>
		<div class="div_fh">
			<br>
		</div>
		<div class="div_f">
			<div class="div_col" id="me">
				<div class="div_c_l">
					<span> 账号</span>
				</div>
				<div class="div_c_r">
					<input type="text" style="width:calc(100% - 16px);" name="account" id="account" placeholder="请设置账号">
					<span style="float: right;margin-top: -30px;background:#fff" id="tish"></span>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="div_f">
			<div class="div_col" id="me">
				<div class="div_c_l">
					<span>密码</span>
				</div>
				<div class="div_c_r">
					<input type="password" style="width:calc(100% - 16px);" name="password" id="password" onkeydown=""
						value="" placeholder="请设置密码" οnkeyup="value=value.replace(/[\W]/g,'') "
						onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
					<span style="float: right;margin-top: -30px;background:#fff" id="ts"></span>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<div class="div_f">
			<div class="div_col" id="me">
				<div class="div_c_l">
					<span style="width:70px;">确认密码</span>
				</div>
				<div class="div_c_r">
					<input type="password" style="width:calc(100% - 16px);" name="passagain" id="Pwdagain" onkeydown=""
						value="" οnkeyup="value=value.replace(/[\W]/g,'') "
						onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
						placeholder="请再次设置密码">
					<span style="float: right;margin-top: -30px;background:#fff" id="tishi"></span>
				</div>
			</div>
			<div style="clear:both"></div>
		</div>
		<button id="submit" class="btn_1" onclick="return checkreg()">确认</button>
	</form>
	<script src="js/larea.js"></script>
	<script>
		//级联选择数组
		var http = localStorage.getItem("http");
		// var SchoolDate = []
		// $.ajax({
		// 	type: "GET",
		// 	url: http + '/student/queryStudentFramework',
		// 	success: response => {
		// 		SchoolDate = response.data.data
		// 	}
		// });
		var SchoolDate = [
			{
				"id": 1,
				"depName": "艾克瑞特",
				"parentId": 0,
				"createTime": 1606544685000,
				"depType": null
			},
			{
				"id": 57,
				"depName": "济南区域",
				"parentId": 1,
				"createTime": 1608291744000,
				"depType": "区域"
			},
			{
				"id": 58,
				"depName": "玉函校区",
				"parentId": 57,
				"createTime": 1608291759000,
				"depType": "校区"
			},
			{
				"id": 59,
				"depName": "领秀城校区",
				"parentId": 57,
				"createTime": 1608426905000,
				"depType": "校区"
			},
			{
				"id": 60,
				"depName": "和谐校区",
				"parentId": 57,
				"createTime": 1608426922000,
				"depType": "校区"
			},
			{
				"id": 61,
				"depName": "恒隆校区",
				"parentId": 57,
				"createTime": 1608426950000,
				"depType": "校区"
			}
		]

		function transDate(list, idstr, pidstr) {
			var result = [], temp = {};
			for (i = 0; i < list.length; i++) {
				temp[list[i][idstr]] = list[i];//将nodes数组转成对象类型  
			}
			for (j = 0; j < list.length; j++) {
				tempVp = temp[list[j][pidstr]]; //获取每一个子对象的父对象  
				if (tempVp) {//判断父对象是否存在，如果不存在直接将对象放到第一层  
					if (!tempVp["child"]) tempVp["child"] = [];//如果父元素的nodes对象不存在，则创建数组  
					tempVp["child"].push(list[j]);//将本对象压入父对象的nodes数组  
				} else {
					result.push(list[j]);//将不存在父对象的对象直接放入一级目录  
				}
			}
			return result;
		}

		let schoolArr = transDate(SchoolDate, "id", "parentId");

		var area1 = new LArea();
		area1.init({
			'trigger': '#demo1', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
			'valueTo': '#value1', //选择完毕后id属性输出到该位置
			'keys': {
				id: 'id',
				name: 'depName'
			}, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
			'type': 1, //数据源类型
			'data': schoolArr //数据源
		});
		area1.value = [0, 0, 0];//控制初始位置，注意：该方法并不会影响到input的value
		//获取到学校的数据及时进行修改
		var schoolarr, scholl;
		//表单验证
		function checkreg() {

			if (document.form1.name.value == "") {
				alert("请输入您孩子的姓名!");
				form1.name.focus();
				return false;
			}
			if (document.form1.sex.value == "") {
				alert("请选择孩子的性别");
				form1.sex.focus();
				return false;
			}

			if (document.form1.schoolval.value == "") {
				alert("请选择孩子的校区");
				form1.school.focus();
				return false;
			}
			if (document.form1.account.value == "") {
				alert("请输入您的账号名");
				form1.account.focus();
				return false;
			}

			if (document.form1.password.value == "") {
				alert("请输入密码!");
				form1.password.focus();
				return false;
			}
			if (document.form1.password.value.length < 6 || document.form1.password.value.length > 20) {
				alert("密码长度限制在6-20位!");
				form1.password.focus();
				return false;
			}

			if (document.form1.password.value != document.form1.Pwdagain.value) {
				alert("两次密码不相同")
				form1.password.focus();
				return false;
			}
			var uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
			if (!uPattern.test(document.form1.account.value)) {
				console.log(document.form1.account.value);
				alert("用户名请输入4到16位（字母，数字，下划线，减号）")
				form1.account.focus();
				return false;
			}
			schoolarr = document.form1.schoolval.value.split(",");
			school = schoolarr[2]
			$.ajax({
				type: "GET",
				url: http + '/addStudent',
				data: {
					"zhenUserName": document.form1.name.value,
					"sex": document.form1.sex.value,
					"depId": school,
					"password": document.form1.password.value,
					"username": document.form1.account.value,
					"parentId": localStorage.getItem("userId"),
				},
				success: function (response) {
					if (confirm("请联系校区老师进行激活")) {
						window.location.href = "../Userlist/Userlist.html"

					}
				}
			});
			return false;


		}
	</script>



</body>

</html>